package com.crimsec.utils.dinfo;

import java.io.IOException;

/**
 * @author moroz
 */
public class RendererFactory {

    /**
     * Construct instance of IRenderer and setup it
     *
     * @param utils, an Utils instance for renderer setup
     * @return instance of IRenderer
     * @throws IOException
     */
    public static IRenderer newRendererInstance(Utils utils) throws IOException {
        try {

            String clz = "com.crimsec.utils.dinfo.impl.SimpleRenderer";
            if (utils.checkProp(IRenderer.class.getName())) {
                clz = utils.getValue(IRenderer.class.getName());
            }
            IRenderer result = (IRenderer) Class.forName(clz).newInstance();
            result.setup(utils);
            return result;
        } catch (Exception e) {
            throw new IOException("could not instantinate renderer class", e);
        }
    }
}
